package com.boyon.customer.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.boyon.customer.domain.AgentReportRateData;
import com.boyon.customer.service.customer.impl.AgentReportRateService;
import com.boyon.hbm.criteria.Query;
import com.boyon.web.param.annotation.ValidatorRequestBody;
import com.boyon.web.response.AbstractResponse;
import com.boyon.web.response.PageResponse;
import com.boyon.web.response.SuccessResponse;

/**
 * ClassName:AgentReportRateAction <br/>
 * Function: 代理商费用比例. <br/>
 * Date: 2018年4月8日 下午9:52:18 <br/>
 * 
 * @author sunshulin
 * @version
 * @since JDK 1.8
 * @see
 */
@Controller
@RequestMapping(value = "/boyon/agent/report/rate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class AgentReportRateAction {

	@Autowired
	private AgentReportRateService agentReportRateService;

	/**
	 * 
	 * query:代理商报告收费比例. <br/>
	 * 
	 * @author sunshulin
	 * @param account
	 * @return
	 * @since JDK 1.8
	 */
	@RequestMapping(value = "/query")
	@ResponseBody
	public PageResponse query(
			@ValidatorRequestBody AgentReportRateData agentReportRateData) {
		Query query = new Query(agentReportRateData.page());
		return new PageResponse(
				agentReportRateService.query(agentReportRateData, query),
				query.getTotal());
	}

	/**
	 * 
	 * find:查找代理商比例. <br/>
	 * 
	 * @author sunshulin
	 * @param agentReportRateData
	 * @return
	 * @since JDK 1.8
	 */
	@RequestMapping(value = "/find")
	@ResponseBody
	public AbstractResponse find(
			@ValidatorRequestBody AgentReportRateData agentReportRateData) {
		return new SuccessResponse(agentReportRateService
				.find(agentReportRateData.getAgentReportRateId()));
	}

	/**
	 * 
	 * delete:删除代理商比例. <br/>
	 * 
	 * @author sunshulin
	 * @param agentReportRateData
	 * @return
	 * @since JDK 1.8
	 */
	@RequestMapping(value = "/delete")
	@ResponseBody
	public AbstractResponse delete(
			@ValidatorRequestBody AgentReportRateData agentReportRateData) {
		agentReportRateService.delete(agentReportRateData.getAgentReportRateId());
		return new SuccessResponse();
	}

	/**
	 * 
	 * editor:编辑代理商报告收费. <br/>
	 * 
	 * @author sunshulin
	 * @param agentReportRateData
	 * @return
	 * @since JDK 1.8
	 */
	@RequestMapping(value = "/editor")
	@ResponseBody
	public AbstractResponse editor(
			@ValidatorRequestBody AgentReportRateData agentReportRateData) {
		agentReportRateService.editor(agentReportRateData);
		return new SuccessResponse();
	}
}
